<?php
/**
 * 异常处理 记录监控日志
 *
 * @author seraph.liujb 2009.8.12
 */

class Common_Exception extends Zend_Exception
{
	/**
	 * 构造
	 * @param string $message 出错信息
	 * @param Exception $e
	 * @return void
	 */
	public function __construct($message = '', Exception $e = null)
	{
		$this->log($message);
		parent::__construct($message,$e);
	}

	/**
	 * 记录错误信息到log系统
	 * @param $message
	 * @return void
	 */
	private function log($message)
	{
		//获取当前请求的MCA“模块-控制器-动作”路径
		$fc = Zend_Controller_Front::getInstance();
		$moduleName = $fc->getRequest()->getModuleName();
		$controllerName = $fc->getRequest()->getControllerName();
		$actionName = $fc->getRequest()->getActionName();
		$class = $moduleName . '-' . $controllerName . '-' . $actionName;
		
		$params = array(
			'type'=>'db',
			'module'=>'web',
			'priority'=>Zend_log::DEBUG,
		);
		$logger = Common_Logger::factory($params);
		$logger->setEventItem('class',$class);
		$logger->setEventItem('thread','http-php');
		$logger->setEventItem('times',time());
		$logger->err($message);
	}
}
